#include "loops.h"
#include "SourceFile.h"
#include <math.h>
#include <QDebug>
#include <QtGlobal>

Loops::Loops()
{
    this->pos=QPoint(Wide,Height);
    this->m_x=Wide;
    this->m_y=Height;
    this->isout=false;
    this->isshot=false;
    this->iscrash=false;

//    this->hadshot=new QSound(Had_Shot);
//    this->hadshot->stop();
//    this->hadshot->setLoops(0);

    this->pllop.resize(Loop_W,Loop_H);
    this->rct.setSize(this->pllop.size()/2);


}

void Loops::shotinit()
{
    this->pllop.resize(Loop_W,Loop_H);
    this->pllop.setPixmap(this->pix);
     this->pllop.setScaledContents(true);

     this->rct.setSize(this->pllop.size());


}

void Loops::updata()
{
    this->pllop.move(this->pos.x(),this->pos.y());
    this->rct.setRect(this->pos.x()+Loop_W/4,this->pos.y()+Loop_H/4,this->pllop.width()/2,this->pllop.height()/2);


}

void Loops::intersets(Toys* toy)
{


    for(int i=0;i<Toy_Num;i++){


        if(this->rct.intersects(toy[i].rct)){

            this->iscrash=true;
            this->pos=toy[i].pos;
            toy[i].isloop=true;
            return ;



        }else{  this->iscrash=false;        }

    }






}
